<script>
import Tools from '@/utils/Tools.js';
export default {
	onLaunch: function(e) {
		this.onStartupScene(e.query);
		// #ifdef MP
		this.updateManager();
		// #endif
		// #ifdef H5
		uni.setStorageSync('entryUrl', encodeURIComponent(location.href.split('#')[0]));
		if (!/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent) && self == top) {
			location.href = '/static/viewport/view.html';
		}
		// #endif
	},
	onShow: function() {
		// console.log('App Show');
	},
	onHide: function() {
		// console.log('App Hide');
	},
	methods: {
		/**
		 * 小程序启动场景
		 */
		onStartupScene(query) {
			// 获取场景值
			let scene = Tools.getSceneData(query);
			// 记录推荐人id
			let refereeId = query.referee_id ? query.referee_id : scene.uid;
			refereeId && Tools.setSuperiorId(refereeId);
		},
		/**
		 * 小程序主动更新
		 */
		updateManager() {
			if (!uni.canIUse('getUpdateManager')) {
				return false;
			}
			const updateManager = uni.getUpdateManager();
			updateManager.onCheckForUpdate(function(res) {
				// 请求完新版本信息的回调
				// console.log(res.hasUpdate)
			});
			updateManager.onUpdateReady(function() {
				uni.showModal({
					title: '更新提示',
					content: '新版本已经准备好，即将重启应用',
					showCancel: false,
					success(res) {
						if (res.confirm) {
							// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
							updateManager.applyUpdate();
						}
					}
				});
			});
			updateManager.onUpdateFailed(function() {
				// 新的版本下载失败
				uni.showModal({
					title: '更新提示',
					content: '新版本下载失败',
					showCancel: false
				});
			});
		}
	},

	onError: function(e) {
		console.error(e);
		const error = {
			token: uni.getStorageSync('token') || '',
			user_id: uni.getStorageSync('user_id') || '',
			error: e
		};
		uni.report('globalError', error);
	}
};
</script>

<style>
/*每个页面公共css */
@import '/static/iconfont/iconfont.css';
@import '/static/font/han-yi/webfont.css';
@import '/style/common.css';

page {
	background: #f7f7f7;
}

.common-header-xian {
	border-top: 1rpx solid #eee;
	position: fixed;
	top: 0;
	width: 100%;
	z-index: 100;
}

.del {
	text-decoration: line-through;
	padding-left: 10rpx;
	color: #999;
}

/* 没有更多 */

.no-more {
	text-align: center;
	color: #737373;
	padding: 10px 0;
}

.yoshop-notcont {
	padding: 130rpx 100rpx;
	box-sizing: border-box;
}

.yoshop-notcont .cont {
	display: block;
	text-align: center;
	font-size: 30rpx;
	color: #999;
	margin-top: 10rpx;
}

.yoshop-notcont .iconfont {
	font-size: 150rpx;
	color: #ccc;
	text-align: center;
	display: block;
	margin-bottom: 12rpx;
}

.yoshop-notcont .img {
	width: 200px;
	height: 120px;
	margin: 0 auto;
}

.yoshop-notcont .img image {
	width: 100%;
	height: 100%;
}

.yoshop-notcont .jump {
	display: block;
	margin: auto;
	margin-top: 20rpx;
	width: 180rpx;
	line-height: 60rpx;
	color: #fff;
	background: #ff5c5c;
	border-radius: 10rpx;
	text-align: center;
	font-size: 30rpx;
}

.bargain-commont-bg {
	background: rgba(0, 0, 0, 0.6);
	position: fixed;
	right: 0;
	left: 0;
	top: 0;
	bottom: 0;
	z-index: 20;
}

.selectNumber {
	height: 26px;
	flex-direction: row;
	border: 1rpx solid rgb(231, 231, 231);
	border-radius: 5rpx;
	display: inline-block;
}

.selectNumber .default {
	width: 30px;
	height: 26px;
	float: left;
	line-height: 24px;
	padding: 0;
	background: #fff;
	color: #444;
	font-size: 40rpx;
	border-radius: unset;
}

.selectNumber .default-active {
	background: #f7f7f7;
	color: #ddd;
}

.selectNumber button:after {
	content: none;
	border: none;
}

.selectNumber input {
	float: left;
	width: 40px;
	height: 26px;
	line-height: 26px;
	border-right: 1rpx solid #eee;
	border-left: 1rpx solid #eee;
	text-align: center;
	font-size: 28rpx;
	color: #444;
}

/* 返回顶部 */

.widget-goTop {
	position: fixed;
	bottom: 150rpx;
	z-index: 10;
	right: 24rpx;
	background: rgba(255, 255, 255, 0.9);
	width: 76rpx;
	height: 76rpx;
	border-radius: 76rpx;
	border: 1rpx solid #eee;
}

.widget-goTop .icon-fanhuidingbu {
	color: #666;
	display: block;
	text-align: center;
	line-height: 76rpx;
	font-size: 32rpx;
}

@-webkit-keyframes rotate {
	0% {
		transform: rotate(0deg) scale(1);
	}

	100% {
		transform: rotate(360deg) scale(1);
	}
}

@keyframes rotate {
	0% {
		transform: rotate(0deg) scale(1);
	}

	100% {
		transform: rotate(360deg) scale(1);
	}
}

/* 底线 */

.title-footer {
	position: relative;
	z-index: 1;
	height: 80rpx;
	line-height: 80rpx;
	overflow: hidden;
	color: #888;
	text-align: center;
	margin: 0 18rpx 0;
}

.title-footer .cont {
	background: #f7f7f7;
	padding: 0 12rpx;
	font-size: 28rpx;
	z-index: 10;
}

.title-footer .hr {
	background: #eee;
	height: 1rpx;
	border: 0;
	position: absolute;
	left: 10%;
	right: 10%;
	top: 50%;
	margin-top: 1px;
	z-index: -1;
}

.slide-image {
	width: 100%;
	height: 100%;
	margin: 0 auto;
	display: block;
}

.goods-comment-box .user {
	margin-right: 15rpx;
}

.goods-comment-box .user_name {
	color: #999;
}

.goods-comment-cont {
	font-size: 30rpx;
	color: #333;
	margin: 10rpx 0;
}

/* 底部操作栏 */

.footer-fixed {
	position: fixed;
	bottom: 0px;
	left: 0px;
	right: 0px;
	display: flex;
	height: 92rpx;
	z-index: 11;
	box-shadow: 0 -2px 20px 0 rgba(144, 52, 52, 0.1);
	background: #fff;
}

/* 底部操作按钮 */

.footer-fixed .opt-btn {
	display: flex;
	text-align: center;
	font-size: 30rpx;
	width: 100%;
	height: 100%;
	justify-content: center;
	align-items: center;
}

.footer-fixed .opt-btn.btn-main {
	background-image: linear-gradient(90deg, #ff387f, #ff2e34);
	color: #fff;
}

.footer-fixed .opt-btn.btn-gray {
	background-color: #ccc;
	color: #fff;
}

/* 废弃 */

.order-bt {
	width: 50%;
	/* background: linear-gradient(to right, #fa1e8c 0, #fc1e56 100%); */
	background-image: linear-gradient(90deg, #ff387f, #ff2e34);
	color: #fff;
	text-align: center;
	line-height: 92rpx;
	font-size: 30rpx;
}

.goods-detail-box {
	padding: 0;
	min-height: 150px;
}

.com_xing .icon-shoucang {
	padding-right: 6rpx;
	color: #ccc;
	font-size: 26rpx;
}

.com_xing .icon-shoucang.active {
	color: #f4a213;
}

.goods-comment-box .left {
	flex: 3;
	position: relative;
}

.goods-comment-box .right {
	flex: 3;
}

.v-hide {
	display: none !important;
}

.v-show {
	display: block !important;
}

.flow-checkout-header {
	padding: 28rpx 0;
	background: #fff
		url('')
		bottom left repeat-x;
	background-size: 120rpx auto;
	position: relative;
}

.flow-header-left {
	/* flex: 14; */
}

.flow-header-right {
	flex: 1;
}

.flow-header-right image {
	width: 34rpx;
	height: 34rpx;
	margin-top: 20rpx;
	float: right;
}

.flow-checkout-header .flow-checkout-address {
	color: #777;
	margin-top: 6rpx;
}

.flow-shopList {
	padding: 18rpx 0;
}

.flow-shopList .flow-list-left {
	margin-right: 20rpx;
}

.flow-shopList .flow-list-left image {
	width: 200rpx;
	height: 200rpx;
	border: 1rpx solid #eee;
	background: #fff;
}

.flow-shopList .flow-list-right .flow-cont {
	font-size: 28rpx;
	color: #ff495e;
}

.flow-shopList .flow-list-right .small {
	font-size: 26rpx;
	color: #777;
}

.flow-shopList .flow-list-right .flow-list-cont {
	padding-top: 10rpx;
}

.flow-fixed-footer {
	position: fixed;
	bottom: 0;
	width: 100%;
	background: #fff;
	border-top: 1px solid #eee;
	z-index: 11;
}

/* 共几件商品 */

.flow-num-box {
	font-size: 28rpx;
	color: #777;
	padding: 16rpx 24rpx;
	text-align: right;
}

.flow-all-money {
	padding: 0 24rpx;
	color: #444;
}

.flow-all-money .flow-all-list {
	font-size: 28rpx;
	padding: 20rpx 0;
	border-bottom: 1rpx solid rgb(248, 248, 248);
}

.flow-all-money .flow-all-list:last-child {
	border-bottom: none;
}

.flow-all-money .flow-all-list-cont {
	font-size: 28rpx;
	padding: 10rpx 0;
}

.flow-all-money .flow-arrow {
	justify-content: flex-end;
	align-items: center;
}

.flow-fixed-footer .chackout-left {
	font-size: 30rpx;
	line-height: 92rpx;
	color: #777;
	flex: 4;
	padding-left: 12px;
}

.flow-fixed-footer .chackout-right {
	font-size: 34rpx;
	flex: 2;
}

.flow-btn {
	background: linear-gradient(to right, #fa1e8c 0, #fc1e56 100%);
	color: #fff;
	text-align: center;
	line-height: 92rpx;
	display: block;
	font-size: 30rpx;
}

.flow-list .header .shop_name {
	padding-left: 10rpx;
	font-size: 30rpx;
	color: #333;
}

.flow-list .header image {
	width: 34rpx;
	height: 37rpx;
	position: absolute;
	top: 50%;
	margin-top: -18rpx;
	left: 15px;
}

.flow-list .header {
	background: #fdf9f9;
	padding: 24rpx 0;
	border-top: 1rpx solid #eee;
	border-bottom: 1rpx solid #eee;
	font-size: 30rpx;
	position: relative;
}

.flow-list .custom-li,
.addres-list .custom-li {
	margin-top: 25rpx;
	display: block;
}

.flow-list .custom-li:first-child,
.addres-list .custom-li:first-child {
	margin-top: 0;
}

.flow-distribution-right .icon-xiangyoujiantou {
	font-size: 26rpx;
	position: absolute;
	right: 15px;
	top: 50%;
	margin-top: -16rpx;
	color: #999;
}

.flow-checkout-address text {
	padding-right: 5rpx;
}

.flow-header-right .icon-xiangyoujiantou {
	position: absolute;
	right: 15px;
	top: 50%;
	margin-top: -13rpx;
	font-size: 32rpx;
	color: #999;
}

.flow-shopList .flow-list-left image {
	width: 180rpx;
	height: 180rpx;
}

.profile-btn button {
	background: linear-gradient(to right, #fa1e8c 0, #fc1e56 100%);
	color: white;
	margin-bottom: 20rpx;
}

.flow-checkout-header .icon-dingwei {
	position: absolute;
	top: 50%;
	left: 15px;
	font-size: 40rpx;
	color: #777;
	margin-top: -20rpx;
}

.index-cont-search {
	width: 100%;
	font-size: 28rpx;
	position: relative;
	background: #f7f7f7;
}

.index-cont-search icon {
	position: absolute;
	left: 50%;
	margin-left: -70rpx;
	top: 50%;
	margin-top: -15rpx;
	height: 30rpx;
	line-height: 30rpx;
}

.index-cont-search text {
	margin-left: 72rpx;
}

@-webkit-keyframes shop {
	0% {
		transform: translateY(-80px);
	}

	50% {
		transform: translateY(0px);
	}

	100% {
		transform: translateY(-80px);
	}
}

@keyframes shop {
	0% {
		transform: translateY(-80px);
	}

	50% {
		transform: translateY(0px);
	}

	100% {
		transform: translateY(-80px);
	}
}

.user-orderJtou {
	color: #777;
	font-size: 26rpx;
}

.address-box .left-name {
	width: 95px;
}

.address-box .right-cont {
	font-size: 30rpx;
	color: #444;
}

.address-box .right-cont input {
	width: 100%;
	font-size: 30rpx;
	color: #444;
}

.address-cont-box picker {
	display: inline-block;
	margin-right: 15px;
	width: 100%;
}

.button {
	border: 1px solid #1aad19;
	border-radius: 2px;
}

.picker {
	padding: 13px;
	background-color: #fff;
}

.profile-list {
	padding: 24rpx 0;
	border-bottom: 1px solid #f6f6f9;
}

.profile-list .admin {
	font-size: 30rpx;
	color: #333;
}

.profile-btn button {
	font-size: 34rpx;
}

.profile-btn button[disabled] {
	background: #f16474;
	color: white;
}

.btn-green button {
	background: #1aad19;
	color: white;
}

.btn-green button[disabled] {
	background: #9de49c;
	color: white;
}

.search-box .left {
	width: 28px;
}

.search-box .left icon {
	padding: 18rpx;
}

.search-box .right {
	flex: 1;
}

.xEmojiView {
	margin: 15rpx 0;
}
.vc-switch {
	bottom: calc(var(--window-bottom) + 20rpx) !important;
	right: 30rpx;
}
</style>
